{{csrf_field()}}
<div class="layui-tab">
    <ul class="layui-tab-title">
        <li class="layui-this">基本信息</li>
        <li>房源介绍</li>
        <li>SEO设置</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <div class="layui-form-item">
                <label for="" class="layui-form-label">所属小区*</label>
                <div class="layui-input-inline">
                    <input type="text" name="communityname" readonly id="selCommunity" value="{{$article->communityname??old('communityname')}}" lay-verify="required" placeholder="请选择小区" class="layui-input" >
                    <input type="hidden" name="community_id" id="communityid" value="{{$article->community_id??old('community_id',0)}}" lay-verify="required">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="" class="layui-form-label">所属区域*</label>
                <div class="layui-input-inline" >
                    <select name="province" id="province" lay-verify="required" lay-filter="myselect">
                        <option value="">请选择省份</option>
                        @foreach($area as $a)
                            <option value="{{$a->id}},{{$a->name}}" @if(isset($article->province)&&$article->province==$a->id)selected @endif>{{$a->name}}</option>
                        @endforeach
                    </select>
                </div>
                <div class="layui-input-inline region-sel" id="city" @if(isset($article->region) && $article->region > 0) style="display:inline;" @endif>
                    <select name="region" id="region" lay-verify="required" lay-filter="myselect2" ></select>
                </div>
                <div class="layui-input-inline area-sel" @if(isset($article->area) && $article->area > 0) style="display:inline;" @endif>
                    <select name="area" id="area" lay-filter="myselect3"></select>
                </div>
                <div class="layui-input-inline town-sel" @if(isset($article->town_id) && $article->town_id > 0) style="display:inline;" @endif>
                    <select name="town" id="town" lay-filter="myselect4"></select>
                </div>
                <input type="hidden" id="province_id" value="{{$article->province??0}}">
                <input type="hidden" id="region_id" value="{{$article->region??0}}">
                <input type="hidden" id="area_id" value="{{$article->area??0}}">
                <input type="hidden" id="town_id" value="{{$article->town_id??0}}">
            </div>
            <div class="layui-form-item metro-sel" @if(isset($article->metro_id) && $article->metro_id > 0) style="display:block;" @endif>
                <label class="layui-form-label">所属地铁线</label>
                <div class="layui-input-inline" >
                    <select name="metro_id" id="metro" lay-verify="required" lay-filter="metroselect"></select>
                </div>
                <div class="layui-input-inline region-sel" id="city" @if(isset($article->region) && $article->region > 0) style="display:inline;" @endif>
                    <select name="metro_station_id" id="station" lay-verify="required" lay-filter="metroselect2" ></select>
                </div>
                <input type="hidden" id="metro_id" value="{{$article->metro_id??0}}">
                <input type="hidden" id="metro_station_id" value="{{$article->metro_station_id??0}}">
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="" class="layui-form-label">房源名称*</label>
                    <div class="layui-input-block" style="width: 300px;">
                        <input type="text" name="title" value="{{$article->title??old('title')}}" lay-verify="required" placeholder="请输入小区名称" class="layui-input" >
                    </div>
                </div>
                <div class="layui-inline">
                    <label for="" class="layui-form-label">户型*</label>
                    <div class="layui-input-inline" style="width: 50px;">
                        <input type="number" name="room" value="{{$article->room??old('room',1)}}" class="layui-input" >
                    </div>
                    <div class="layui-form-mid layui-word-aux">室</div>
                    <div class="layui-input-inline" style="width: 50px;">
                        <input type="number" name="hall" value="{{$article->hall??old('hall',1)}}" class="layui-input" >
                    </div>
                    <div class="layui-form-mid layui-word-aux">厅</div>
                    <div class="layui-input-inline" style="width: 50px;">
                        <input type="number" name="kitchen" value="{{$article->kitchen??old('kitchen',1)}}" class="layui-input" >
                    </div>
                    <div class="layui-form-mid layui-word-aux">厨</div>
                    <div class="layui-input-inline" style="width: 50px;">
                        <input type="number" name="toilet" value="{{$article->toilet??old('toilet',1)}}" class="layui-input" >
                    </div>
                    <div class="layui-form-mid layui-word-aux">卫</div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="" class="layui-form-label">朝向</label>
                    <div class="layui-input-inline">
                        <select name="category_id">
                            <option value=""></option>
                            @foreach($categorys as $category)
                                <option value="{{ $category->id }},{{ $category->name }}" @if(isset($article->category_id)&&$article->category_id==$category->id)selected @endif >{{ $category->name }}</option>
                            @endforeach
                        </select>
                    </div>
                    <label for="" class="layui-form-label">面积*</label>
                    <div class="layui-input-inline">
                        <input type="text" name="acreage" value="{{$article->acreage??old('acreage')}}" placeholder="120" class="layui-input" >
                    </div>
                    <div class="layui-form-mid layui-word-aux">㎡</div>
                    <div class="layui-form-mid layui-word-aux">月租</div>
                    <div class="layui-input-inline">
                        <input type="text" name="price" value="{{$article->price??old('price')}}" placeholder="3000" class="layui-input" >
                    </div>
                    <div class="layui-form-mid layui-word-aux">元/月</div>
                </div>
            </div>
            <div class="layui-form-item" style="display: flex;">
                <div class="layui-inline">
                    <label for="" class="layui-form-label">地图标注 *</label>
                    <div class="layui-input-inline" style="width:300px;">
                        <input type="text" name="map" id="map" value="{{$article->map??old('map')}}" lay-verify="required" placeholder="标注楼盘经纬度" class="layui-input" >
                    </div>
                </div>
                <button type="button" class="layui-btn layui-btn-danger"  id="getmap">获取标注</button>
{{--                <input type="hidden" id="uri" value="{{env('APP_URI')}}">--}}
            </div>
            <div class="layui-form-item layui-form-text">
                <div class="layui-block">
                    <label for="" class="layui-form-label">房源地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="address" value="{{$article->address??old('address')}}" placeholder="详细地址" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-block">
                    <label for="" class="layui-form-label">楼层</label>
                    <div class="layui-input-inline">
                        <select name="floor">
                            <option value="低层" @if(isset($article->floor) && $article->floor == '低层') selected @endif>低层</option>
                            <option value="中层" @if(isset($article->floor) && $article->floor == '中层') selected @endif>中层</option>
                            <option value="高层" @if(isset($article->floor) && $article->floor == '高层') selected @endif>高层</option>
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">共</div>
                    <div class="layui-input-inline">
                        <input type="number" name="floor_num" value="{{$article->floor_num??old('floor_num')}}" placeholder="20" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">层</div>
                    <label for="" class="layui-form-label">建筑年代 *</label>
                    <div class="layui-input-inline">
                        <input type="number" name="year" lay-verify="required" value="{{$article->year??old('year')}}" placeholder="2019" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-block">
                    <label for="" class="layui-form-label">装修情况</label>
                    <div class="layui-input-block">
                        @if(isset($renovation) && !$renovation->isEmpty())
                            @foreach($renovation as $re)
                                <input type="radio" name="renovation" @if(isset($article->renovation) && $re->id == $article->renovation) checked @endif value="{{$re->id}},{{$re->name}}" title="{{$re->name}}" lay-skin="primary">
                            @endforeach
                        @endif
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="" class="layui-form-label">联系人</label>
                    <div class="layui-input-inline">
                        <input type="text" name="contact_name" value="{{$article->contact_name??old('contact_name')}}" placeholder="姓名" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label for="" class="layui-form-label">联系电话</label>
                    <div class="layui-input-inline">
                        <input type="text" name="contact_tel" value="{{$article->contact_tel??old('contact_tel')}}" placeholder="电话" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="" class="layui-form-label">租赁方式</label>
                    <div class="layui-input-inline">
                        <select name="rental_type" lay-verify="required">
                            <option value="A" @if(isset($article->rental_type) && $article->rental_type == 'A') selected @endif>整租</option>
                            <option value="B" @if(isset($article->rental_type) && $article->rental_type == 'B') selected @endif>合租</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label for="" class="layui-form-label">支付方式</label>
                    <div class="layui-input-inline">
                        <select name="pay_type" lay-verify="required">
                            <option value="0" @if(isset($article->pay_type) && $article->pay_type == 0) selected @endif>押一付一</option>
                            <option value="1" @if(isset($article->pay_type) && $article->pay_type == 1) selected @endif>押一付三</option>
                            <option value="2" @if(isset($article->pay_type) && $article->pay_type == 2) selected @endif>押二付三</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-block">
                    <label for="" class="layui-form-label">房间配套</label>
                    <div class="layui-input-block">
                        @if(isset($supporting) && !$supporting->isEmpty())
                            @foreach($supporting as $su)
                                <input type="checkbox" name="supporting[]" @if(isset($article->supporting) && in_array($su->id,$article->supporting)) checked @endif value="{{$su->id}}" title="{{$su->name}}" lay-skin="primary">
                            @endforeach
                        @endif
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="" class="layui-form-label">物业类型</label>
                    <div class="layui-input-block" style="display: flex;flex-wrap: wrap;">
                        @if(isset($pm_type)&&!$pm_type->isEmpty())
                            @foreach($pm_type as $o)
                                <input type="radio" name="pm_type" @if(isset($article->pm_type) && $o->id == $article->pm_type) checked @endif value="{{$o->id}}" title="{{$o->name}}" lay-skin="primary">
                            @endforeach
                        @endif
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="" class="layui-form-label">特色</label>
                    <div class="layui-input-block" style="display: flex;flex-wrap: wrap;">
                        @if(isset($tags) && !$tags->isEmpty())
                            @foreach($tags as $t)
                                <input type="checkbox" name="tags[]" @if(isset($article->tags) && in_array($t->id,$article->tags)) checked @endif value="{{$t->id}}" title="{{$t->name}}" lay-skin="primary">
                            @endforeach
                        @endif
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-block">
                    <label for="" class="layui-form-label">推荐位</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="rec" value="r" @if(!empty($article->rec) &&  $article->rec == 'r') checked @endif title="推荐" lay-skin="primary">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-block">
                    <label for="" class="layui-form-label">有效期</label>
                    <div class="layui-input-inline">
                        <select name="daytime">
                            <option value="1" @if(isset($article->daytime) && $article->daytime == 1) selected @endif>1天</option>
                            <option value="3" @if(isset($article->daytime) && $article->daytime == 3) selected @endif>3天</option>
                            <option value="5" @if(isset($article->daytime) && $article->daytime == 5) selected @endif>5天</option>
                            <option value="7" @if(isset($article->daytime) && $article->daytime == 7) selected @endif>7天</option>
                            <option value="10" @if(isset($article->daytime) && $article->daytime == 10) selected @endif>10天</option>
                            <option value="15" @if(isset($article->daytime) && $article->daytime == 15) selected @endif>15天</option>
                            <option value="20" @if(isset($article->daytime) && $article->daytime == 20) selected @endif>20天</option>
                            <option value="25" @if(isset($article->daytime) && $article->daytime == 25) selected @endif>25天</option>
                            <option value="30" @if(isset($article->daytime) && $article->daytime == 30) selected @endif>30天</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="" class="layui-form-label">缩略图 *</label>
                <div class="layui-input-block">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn layui-btn-normal" id="uploadPic"><i class="layui-icon">&#xe67c;</i>图片上传</button>
                        <span>图片尺寸：600*400</span>
                        <div class="layui-upload-list" >
                            <ul id="layui-upload-box" class="layui-clear">
                                @if(isset($article->thumb))
                                    <li><img src="{{ $article->thumb }}" /><p>上传成功</p></li>
                                @endif
                            </ul>
                            <input type="hidden" name="thumb" id="thumb" value="{{ $article->thumb??'' }}">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="" class="layui-form-label">房源图片</label>
                <div class="layui-input-block">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn layui-btn-normal" id="uploadImages"><i class="layui-icon">&#xe67c;</i>图片上传</button>
                        <div class="layui-upload-list" >
                            <ul id="layui-upload-image-box" class="layui-clear xiangce">
                                @if(isset($article->images) && !$article->images == '')
                                    @foreach($article->images as $k=>$m)
                                        <li>
                                            <img src="{{ $m['smallimg'] }}" /><p>上传成功</p>
                                            <input type="hidden" name="images[{{$k}}][bigimg]" value="{{ $m['bigimg'] }}">
                                            <input type="hidden" name="images[{{$k}}][smallimg]" value="{{ $m['smallimg'] }}">
                                            <span class="layui-icon layui-icon-close-fill close-img" onclick="delImage(this)"></span>
                                        </li>
                                    @endforeach
                                @endif
                            </ul>
                            <div class="images-list"></div>
                            @if(!empty($article->images))
                                <input type="hidden" id="imgnum" value="{{count($article->images)}}">
                            @else
                                <input type="hidden" id="imgnum" value="0">
                            @endif
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-block">
                    <label for="" class="layui-form-label">全景看房</label>
                    <div class="layui-input-block">
                        <input type="text" name="overall_view" value="{{$article->overall_view??old('overall_view')}}" placeholder="在720yun.com创建全景相册,复制链接地址到输入框" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="" class="layui-form-label">状态 *</label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="T" title="在租" @if(isset($article->status) && $article->status == 'T') checked @elseif(!isset($article->status)) checked @endif>
                    <input type="radio" name="status" value="F" title="已租出" @if(isset($article->status) && $article->status == 'F') checked @endif>
                </div>
            </div>
        </div>
        <div class="layui-tab-item">
            @include('UEditor::head')
            <div class="layui-form-item">
                <label for="" class="layui-form-label">房源介绍</label>
                <div class="layui-input-block">
                    <script id="container" name="content" type="text/plain">
                        {!! $article->content??old('content') !!}
                    </script>
                </div>
            </div>
        </div>
        <div class="layui-tab-item">
            <div class="layui-form-item">
                <label for="" class="layui-form-label">SEO标题</label>
                <div class="layui-input-block">
                    <input type="text" name="seo_title" value="{{$article->seo_title??old('seo_title')}}" class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item">
                <label for="" class="layui-form-label">SEO关键词</label>
                <div class="layui-input-block">
                    <input type="text" name="seo_keywords" value="{{$article->seo_keywords??old('seo_keywords')}}" class="layui-input" >
                </div>
            </div>

            <div class="layui-form-item">
                <label for="" class="layui-form-label">SEO描述</label>
                <div class="layui-input-block">
                    <textarea name="seo_description" placeholder="请输入描述" class="layui-textarea">{{$article->seo_description??old('seo_description')}}</textarea>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="layui-form-item" style="padding-bottom:20px;">
    <div class="layui-input-block">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formDemo">确 认</button>
        <a  class="layui-btn" href="{{route('admin.rentalhouse')}}" >返 回</a>
    </div>
</div>